var fs = require("fs");
var path = require("path");

var filePath = path.join(__dirname, "/1.txt");
var readable = fs.createReadStream(filePath); //fs.createReadStream 从当前文件位置顺序读取
readable.on("data", function(chunk){ 
    console.log(chunk.toString("utf8"));
})
readable.on("end",function(){
    console.log(" readable ended")
})

readable.pipe(process.stdout); //把可读流readable连接到可写流，然后输出
/**
 * 有readable.pipe(process.stdout);则输出
 * 啊哈哈哈哈哈哈哈哈哈
 * 啊哈哈哈哈哈哈哈哈哈 readable ended
 * 
 * 没有readable.pipe(process.stdout);则输出
 * 啊哈哈哈哈哈哈哈哈哈
 * readable ended
 */